<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        body {
            display: flex;
            justify-content: center;
        }

        div {
            display: flex;
        }
        .list{
            display: flex;
        }
        .list li {
            list-style-type: none;
            width: 100px;
            height: 50px;
            line-height: 50px;
            background-color: beige;
            text-align: center;
            border-radius: 16px;
        }
        .list li span{
            width: 100%;
            height: 100%;
        }
        li:hover{
            cursor: pointer;
        }
    </style>
</head>

<body>
    <div>
        <ul class="list">
            <li>
                <span>
                    第一个
                </span>
            </li>
            <li>
                <span>
                    第二个
                </span>
            </li>
            <li>
                <span>
                    第三个
                </span>
            </li>
            <li>
                <span>
                    第四个
                </span>
            </li>
            <li>
                <span>
                    第五个
                </span>
            </li>
        </ul>
    </div>
</body>
<script>
    var spanlist = document.querySelectorAll('.list li span');
    spanlist.forEach(item => {
        console.log(item);
        
        item.addEventListener('click',function(){
            item.parentElement.style.backgroundColor='red';
        })
    });
</script>
</html>